Add a Q_() macro.
authorMatthias Clasen <maclas@gmx.de>
Mon, 17 May 2004 02:33:18 +0000 (02:33 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 17 May 2004 02:33:18 +0000 (02:33 +0000)
Sun May 16 22:27:17 2004  Matthias Clasen  <maclas@gmx.de>

* gtk/gtkintl.h (Q_): Add a Q_() macro.

* gtk/gtkcellrendererprogress.h: Remove GTK_PROGRESS_CELL_UNKNOWN
and GTK_PROGRESS_CELL_FAILED. With the ability the set the label,
they are not really needed.

* gtk/gtkcellrendererprogress.c: Use the xpad and ypad properties
instead of hardwired padding, use Q_() for the default label,
compute a reasonable minimal size.  (#142571, #142572, #142573,
Tommi Komulainen, Christian Persch)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkcellrendererprogress.c
gtk/gtkcellrendererprogress.h
gtk/gtkintl.h

index c8f52e87f254e5d83dc9ac06855707026553a3ea..acc6727ac5b048d929643c4dbb65904ea1b0f4ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Sun May 16 22:27:17 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkintl.h (Q_): Add a Q_() macro. 
+
+       * gtk/gtkcellrendererprogress.h: Remove GTK_PROGRESS_CELL_UNKNOWN
+       and GTK_PROGRESS_CELL_FAILED. With the ability the set the label,
+       they are not really needed.
+
+       * gtk/gtkcellrendererprogress.c: Use the xpad and ypad properties
+       instead of hardwired padding, use Q_() for the default label, 
+       compute a reasonable minimal size.  (#142571, #142572, #142573,
+       Tommi Komulainen, Christian Persch)
+       
 2004-05-15  Tor Lillqvist  <tml@iki.fi>
 
        * gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the
index c8f52e87f254e5d83dc9ac06855707026553a3ea..acc6727ac5b048d929643c4dbb65904ea1b0f4ba 100644 (file)
@@ -1,3 +1,16 @@
+Sun May 16 22:27:17 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkintl.h (Q_): Add a Q_() macro. 
+
+       * gtk/gtkcellrendererprogress.h: Remove GTK_PROGRESS_CELL_UNKNOWN
+       and GTK_PROGRESS_CELL_FAILED. With the ability the set the label,
+       they are not really needed.
+
+       * gtk/gtkcellrendererprogress.c: Use the xpad and ypad properties
+       instead of hardwired padding, use Q_() for the default label, 
+       compute a reasonable minimal size.  (#142571, #142572, #142573,
+       Tommi Komulainen, Christian Persch)
+       
 2004-05-15  Tor Lillqvist  <tml@iki.fi>
 
        * gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the
index c8f52e87f254e5d83dc9ac06855707026553a3ea..acc6727ac5b048d929643c4dbb65904ea1b0f4ba 100644 (file)
@@ -1,3 +1,16 @@
+Sun May 16 22:27:17 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkintl.h (Q_): Add a Q_() macro. 
+
+       * gtk/gtkcellrendererprogress.h: Remove GTK_PROGRESS_CELL_UNKNOWN
+       and GTK_PROGRESS_CELL_FAILED. With the ability the set the label,
+       they are not really needed.
+
+       * gtk/gtkcellrendererprogress.c: Use the xpad and ypad properties
+       instead of hardwired padding, use Q_() for the default label, 
+       compute a reasonable minimal size.  (#142571, #142572, #142573,
+       Tommi Komulainen, Christian Persch)
+       
 2004-05-15  Tor Lillqvist  <tml@iki.fi>
 
        * gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the
index c8f52e87f254e5d83dc9ac06855707026553a3ea..acc6727ac5b048d929643c4dbb65904ea1b0f4ba 100644 (file)
@@ -1,3 +1,16 @@
+Sun May 16 22:27:17 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkintl.h (Q_): Add a Q_() macro. 
+
+       * gtk/gtkcellrendererprogress.h: Remove GTK_PROGRESS_CELL_UNKNOWN
+       and GTK_PROGRESS_CELL_FAILED. With the ability the set the label,
+       they are not really needed.
+
+       * gtk/gtkcellrendererprogress.c: Use the xpad and ypad properties
+       instead of hardwired padding, use Q_() for the default label, 
+       compute a reasonable minimal size.  (#142571, #142572, #142573,
+       Tommi Komulainen, Christian Persch)
+       
 2004-05-15  Tor Lillqvist  <tml@iki.fi>
 
        * gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the
index 64116d2ed28daf2fbf4829c0fe4c70132c5f15d5..c76f4b6d1d898bd37f1f1b872a611f6b858e75f6 100644 (file)
@@ -34,9 +34,6 @@
                                                                                      GTK_TYPE_CELL_RENDERER_PROGRESS, \
                                                                                      GtkCellRendererProgressPrivate))
 
-#define XPAD 4
-#define YPAD 8
-
 enum
 {
        PROP_0,
@@ -65,8 +62,9 @@ static void gtk_cell_renderer_progress_set_property (GObject                 *ob
 static void gtk_cell_renderer_progress_set_value    (GtkCellRendererProgress *cellprogress,
                                                     gint                     value);
 static void gtk_cell_renderer_progress_set_text     (GtkCellRendererProgress *cellprogress,
-                                                    gchar                   *text);
-static void compute_dimensions                      (GtkWidget               *widget,
+                                                    const gchar             *text);
+static void compute_dimensions                      (GtkCellRenderer         *cell,
+                                                    GtkWidget               *widget,
                                                     const gchar             *text,
                                                     gint                    *width,
                                                     gint                    *height);
@@ -114,7 +112,7 @@ gtk_cell_renderer_progress_class_init (GtkCellRendererProgressClass *klass)
                                   g_param_spec_int ("value",
                                                     P_("Value"),
                                                     P_("Value of the progress bar"),
-                                                    -2, 100, 0,
+                                                    0, 100, 0,
                                                     G_PARAM_READWRITE));
 
   /**
@@ -147,6 +145,7 @@ gtk_cell_renderer_progress_init (GtkCellRendererProgress *cellprogress)
   cellprogress->priv->text = NULL;
   cellprogress->priv->label = NULL;
   cellprogress->priv->min_w = -1;
+  cellprogress->priv->min_h = -1;
 }
 
 
@@ -230,19 +229,9 @@ gtk_cell_renderer_progress_set_value (GtkCellRendererProgress *cellprogress,
 
   if (cellprogress->priv->text)
     text = g_strdup (cellprogress->priv->text);
-  else if (cellprogress->priv->value == GTK_PROGRESS_CELL_FAILED)
-    /* Translator hint: this is a label on progress bars inside a tree view. 
-     */
-    text = g_strdup (_("Failed"));
-  else if (cellprogress->priv->value == GTK_PROGRESS_CELL_UNKNOWN)
-    /* Translator hint: this is a label on progress bars inside a tree view. 
-     */
-    text = g_strdup (_("Unknown"));
   else
-    /* Translator hint: this is the default label on progress bars
-     * inside a tree view. %d will be replaced by the percentage 
-     */
-    text = g_strdup_printf (_("%d %%"), cellprogress->priv->value);
+    text = g_strdup_printf (Q_("progress bar label|%d %%"), 
+                           cellprogress->priv->value);
   
   g_free (cellprogress->priv->label);
   cellprogress->priv->label = text;
@@ -250,7 +239,7 @@ gtk_cell_renderer_progress_set_value (GtkCellRendererProgress *cellprogress,
 
 static void
 gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress, 
-                                    gchar                   *text)
+                                    const gchar             *text)
 {
   gchar *new_text;
 
@@ -263,10 +252,11 @@ gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress,
 }
 
 static void
-compute_dimensions (GtkWidget   *widget, 
-                   const gchar *text, 
-                   gint        *width, 
-                   gint        *height)
+compute_dimensions (GtkCellRenderer *cell,
+                   GtkWidget       *widget, 
+                   const gchar     *text, 
+                   gint            *width, 
+                   gint            *height)
 {
   PangoRectangle logical_rect;
   PangoLayout *layout;
@@ -275,10 +265,10 @@ compute_dimensions (GtkWidget   *widget,
   pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
   
   if (width)
-    *width = logical_rect.width + XPAD * 2 + widget->style->xthickness * 2;
+    *width = logical_rect.width + cell->xpad * 2 + widget->style->xthickness * 2;
   
   if (height)
-    *height = logical_rect.height + YPAD * 2 + widget->style->ythickness * 2;
+    *height = logical_rect.height + cell->ypad * 2 + widget->style->ythickness * 2;
   
   g_object_unref (G_OBJECT (layout));
 }
@@ -294,13 +284,18 @@ gtk_cell_renderer_progress_get_size (GtkCellRenderer *cell,
 {
   GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (cell);
   gint w, h;
-  
+  gchar *text;
+
   if (cellprogress->priv->min_w < 0)
-    compute_dimensions (widget, _("Unknown"),
-                       &cellprogress->priv->min_w,
-                       &cellprogress->priv->min_h);
+    {
+      text = g_strdup_printf (Q_("progress bar label|%d %%"), 100);
+      compute_dimensions (cell, widget, text,
+                         &cellprogress->priv->min_w,
+                         &cellprogress->priv->min_h);
+      g_free (text);
+    }
   
-  compute_dimensions (widget, cellprogress->priv->label, &w, &h);
+  compute_dimensions (cell, widget, cellprogress->priv->label, &w, &h);
   
   if (width)
       *width = MAX (cellprogress->priv->min_w, w);
@@ -330,11 +325,11 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
   
   gc = gdk_gc_new (window);
   
-  x = cell_area->x + XPAD;
-  y = cell_area->y + YPAD;
+  x = cell_area->x + cell->xpad;
+  y = cell_area->y + cell->ypad;
   
-  w = cell_area->width - XPAD * 2;
-  h = cell_area->height - YPAD * 2;
+  w = cell_area->width - cell->xpad * 2;
+  h = cell_area->height - cell->ypad * 2;
   
   gdk_gc_set_rgb_fg_color (gc, &widget->style->fg[GTK_STATE_NORMAL]);
   gdk_draw_rectangle (window, gc, TRUE, x, y, w, h);
@@ -347,7 +342,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
   gdk_draw_rectangle (window, gc, TRUE, x, y, w, h);
   
   gdk_gc_set_rgb_fg_color (gc, &widget->style->bg[GTK_STATE_SELECTED]);
-  perc_w = w * cellprogress->priv->value / 100;
+  perc_w = w * MAX (0, cellprogress->priv->value) / 100;
   gdk_draw_rectangle (window, gc, TRUE, is_rtl ? (x + w - perc_w) : x, y, perc_w, h);
   
   layout = gtk_widget_create_pango_layout (widget, cellprogress->priv->label);
index 7417f79063501e1aff2881599510a79b5dc0bc88..dddc71ea80494485e381cc23462523991d7f9791 100644 (file)
@@ -42,12 +42,6 @@ typedef struct _GtkCellRendererProgress         GtkCellRendererProgress;
 typedef struct _GtkCellRendererProgressClass    GtkCellRendererProgressClass;
 typedef struct _GtkCellRendererProgressPrivate  GtkCellRendererProgressPrivate;
 
-enum
-{
-  GTK_PROGRESS_CELL_UNKNOWN = -1,
-  GTK_PROGRESS_CELL_FAILED = -2
-};
-
 struct _GtkCellRendererProgress
 {
   GtkCellRenderer parent_instance;
index 8ac9475939f76654fd52e4eea8be042a08486faa..9f66ec1e7fd613410d7a3f00bcad080ecd9f0b84 100644 (file)
@@ -2,11 +2,13 @@
 #define __GTKINTL_H__
 
 #include "config.h"
+#include <glib.h>
 
 #ifdef ENABLE_NLS
-#include<libintl.h>
+#include <libintl.h>
 #define _(String) dgettext(GETTEXT_PACKAGE,String)
 #define P_(String) dgettext(GETTEXT_PACKAGE "-properties",String)
+#define Q_(String) g_strip_context ((String), gettext (String))
 #ifdef gettext_noop
 #define N_(String) gettext_noop(String)
 #else
@@ -16,6 +18,7 @@
 #define _(String) (String)
 #define P_(String) (String)
 #define N_(String) (String)
+#define Q_(String) (String)
 #define textdomain(String) (String)
 #define gettext(String) (String)
 #define dgettext(Domain,String) (String)